package nape.geom;
import zpp_nape.Config;
import zpp_nape.Const;
import zpp_nape.util.Flags;
import DummyNapeMain;
import zpp_nape.util.Math;
import zpp_nape.util.Names;
import zpp_nape.util.Pool;
import zpp_nape.util.Lists;
import zpp_nape.shape.Circle;
import zpp_nape.shape.Edge;
import zpp_nape.space.Space;
import zpp_nape.shape.Polygon;
import zpp_nape.shape.Shape;
import zpp_nape.phys.FeatureMix;
import zpp_nape.phys.FluidProperties;
import zpp_nape.phys.Material;
import zpp_nape.phys.Body;
import zpp_nape.geom.AABB;
import zpp_nape.geom.Distance;
import zpp_nape.geom.Mat23;
import zpp_nape.geom.Vec2;
import zpp_nape.geom.VecMath;
import zpp_nape.geom.Collide;
import zpp_nape.dynamics.Arbiter;
import zpp_nape.dynamics.Contact;
import zpp_nape.dynamics.InteractionFilter;
import zpp_nape.constraint.Constraint;
import zpp_nape.dynamics.SpaceArbiterList;
import zpp_nape.constraint.Matrices;
import zpp_nape.constraint.PivotJoint;
import zpp_nape.constraint.WeldJoint;
import nape.util.Flags;
import nape.util.Lists;
import nape.util.Debug;
import nape.space.Space;
import nape.shape.Circle;
import nape.shape.Polygon;
import nape.shape.Edge;
import nape.shape.Shape;
import nape.phys.FluidProperties;
import nape.phys.Material;
import nape.phys.Body;
import nape.geom.AABB;
import nape.geom.Mat23;
import nape.geom.Vec2;
import nape.dynamics.Contact;
import nape.dynamics.Arbiter;
import nape.dynamics.InteractionFilter;
#if swc@:keep#end class Geom{
    #if swc@:keep#end public static function distance(shape1:Shape,shape2:Shape,out1:Vec2,out2:Vec2){
        if(out1.zpp_inner.immutable||out2.zpp_inner.immutable)throw "Error: Supplied Vec2 are immutable";
        if(out1.zpp_inner._immutable!=null)out1.zpp_inner._immutable();
        if(out2.zpp_inner._immutable!=null)out2.zpp_inner._immutable();
        if(shape1.body==null||shape2.body==null)throw "Error: Shape must be part of a Body to calculate distances";
        var rev=false;
        if(shape1.isPolygon()&&shape2.isCircle()){
            rev=true;
            {
                var t=shape1;
                shape1=shape2;
                shape2=t;
            };
        }
        shape1.zpp_inner.validate_worldCOM();
        shape2.zpp_inner.validate_worldCOM();
        var ret=ZPP_Distance.distance(out1.zpp_inner,out2.zpp_inner,shape1.zpp_inner,shape2.zpp_inner,null);
        if(rev){
            {
                var t=out1.x;
                out1.x=out2.x;
                out2.x=t;
            };
            {
                var t=out1.y;
                out1.y=out2.y;
                out2.y=t;
            };
        }
        return ret;
    }
}
